<!DOCTYPE html>
<html>
<head>
    

    

    
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?a7c05ce530152d9866930ef4850ee566"></script>
<!-- End Baidu Tongji -->




    <meta charset="utf-8">
    
    
    
    <title>Mybatis快速入门三(全局配置) | 神奇的鸭鸭の码农库 | 新知识要不断的总结记录成笔记，要多写，多画，能够清晰透彻的将知识讲给别人听，才是达到理解的层次。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#765959">
    
    
    <meta name="keywords" content="SSM">
    <meta name="description" content="Mybatis全局配置我们在前面的教程中编写了mybatis的全局配置文件mybatis-config.xml，该文件是mybatis的全局配置文件(名称任意)，该配置文件内容和顺序如下(顺序不能乱)：  mybatis-config.xml 配置 properties 属性 settings 设置 typeAliases 类型别名 typeHandlers 类型处理器 objectFactory">
<meta name="keywords" content="SSM">
<meta property="og:type" content="article">
<meta property="og:title" content="Mybatis快速入门三(全局配置)">
<meta property="og:url" content="http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/index.html">
<meta property="og:site_name" content="神奇的鸭鸭の码农库">
<meta property="og:description" content="Mybatis全局配置我们在前面的教程中编写了mybatis的全局配置文件mybatis-config.xml，该文件是mybatis的全局配置文件(名称任意)，该配置文件内容和顺序如下(顺序不能乱)：  mybatis-config.xml 配置 properties 属性 settings 设置 typeAliases 类型别名 typeHandlers 类型处理器 objectFactory">
<meta property="og:updated_time" content="2017-12-05T09:57:59.382Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Mybatis快速入门三(全局配置)">
<meta name="twitter:description" content="Mybatis全局配置我们在前面的教程中编写了mybatis的全局配置文件mybatis-config.xml，该文件是mybatis的全局配置文件(名称任意)，该配置文件内容和顺序如下(顺序不能乱)：  mybatis-config.xml 配置 properties 属性 settings 设置 typeAliases 类型别名 typeHandlers 类型处理器 objectFactory">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.4.3">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">神奇的鸭鸭</h5>
          <a href="mailto:702038338@qq.com" title="702038338@qq.com" class="mail">702038338@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/magic_duck" target="_blank" >
                <i class="icon icon-lg icon-gg-circle"></i>
                码云
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://www.zhihu.com/people/shen-qi-de-ya-ya" target="_blank" >
                <i class="icon icon-lg icon-twitter"></i>
                知乎
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404页面测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Mybatis快速入门三(全局配置)</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">Mybatis快速入门三(全局配置)</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-08-13T07:55:00.000Z" itemprop="datePublished" class="page-time">
  2017-08-13
</time>


            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Mybatis全局配置"><span class="post-toc-number">1.</span> <span class="post-toc-text">Mybatis全局配置</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#完整的mybatis配置文件结构如下"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">完整的mybatis配置文件结构如下</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Properties"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">Properties</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Settings"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">Settings</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#typeAliases"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">typeAliases</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#typeHandlers"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">typeHandlers</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#objectFactory"><span class="post-toc-number">1.6.</span> <span class="post-toc-text">objectFactory</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#plugins"><span class="post-toc-number">1.7.</span> <span class="post-toc-text">plugins</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#environments"><span class="post-toc-number">1.8.</span> <span class="post-toc-text">environments</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#mappers"><span class="post-toc-number">1.9.</span> <span class="post-toc-text">mappers</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-Mybatis_primary_03"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">Mybatis快速入门三(全局配置)</h1>
        <div class="post-meta">
            <time class="post-time" title="2017年08月13日 15:55" datetime="2017-08-13T07:55:00.000Z"  itemprop="datePublished">2017-08-13</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="Mybatis全局配置"><a href="#Mybatis全局配置" class="headerlink" title="Mybatis全局配置"></a>Mybatis全局配置</h2><p>我们在前面的教程中编写了mybatis的全局配置文件mybatis-config.xml，该文件是mybatis的全局配置文件(名称任意)，该配置文件内容和顺序如下(顺序不能乱)：</p>
<ul>
<li>mybatis-config.xml 配置<ul>
<li>properties 属性</li>
<li>settings 设置</li>
<li>typeAliases 类型别名</li>
<li>typeHandlers 类型处理器</li>
<li>objectFactory 对象工程</li>
<li>plugins 插件</li>
<li>environments 环境<ul>
<li>environment 环境变量</li>
<li>transactionManager 事务管理器</li>
<li>dataSource 数据源</li>
</ul>
</li>
<li>databaseIdProvider 数据库供应商标识</li>
<li>mappers 映射器</li>
</ul>
</li>
</ul>
<h3 id="完整的mybatis配置文件结构如下"><a href="#完整的mybatis配置文件结构如下" class="headerlink" title="完整的mybatis配置文件结构如下"></a>完整的mybatis配置文件结构如下</h3><p>标注来源：<a href="http://blog.csdn.net/summer_yuxia/article/details/53169227" target="_blank" rel="external">MyBatis xml配置文件详解</a><br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;</div><div class="line"><span class="meta">&lt;!DOCTYPE configuration</span></div><div class="line"><span class="meta">  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"</span></div><div class="line"><span class="meta">  "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;</span></div><div class="line"><span class="comment">&lt;!-- 配置mybatis的环境文件 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 属性：定义配置外在化 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">properties</span>&gt;</span><span class="tag">&lt;/<span class="name">properties</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 设置：定义mybatis的一些全局性信息 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">settings</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!-- 具体的参数名和参数值 --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">""</span> <span class="attr">value</span>=<span class="string">""</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">settings</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 类型名称：为一些类定义别名 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">typeAliases</span>&gt;</span><span class="tag">&lt;/<span class="name">typeAliases</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 类型处理器：定义java类型与数据库中的数据类型之间的转换关系 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">typeHandlers</span>&gt;</span><span class="tag">&lt;/<span class="name">typeHandlers</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 对象工厂 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">objectFactory</span> <span class="attr">type</span>=<span class="string">""</span>&gt;</span><span class="tag">&lt;/<span class="name">objectFactory</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 插件：mybatis的插件，插件可以修改mybatis的内部运行规则 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">plugin</span> <span class="attr">interceptor</span>=<span class="string">""</span>&gt;</span><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 环境：配置mybatis环境 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">environments</span> <span class="attr">default</span>=<span class="string">""</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!-- 环境变量：可以配置多个环境变量，比如使用多数据源时，就需要配置多个环境变量 --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">environment</span> <span class="attr">id</span>=<span class="string">""</span>&gt;</span></div><div class="line">      <span class="comment">&lt;!-- 事务管理器 --&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">transactionManager</span> <span class="attr">type</span>=<span class="string">""</span>&gt;</span><span class="tag">&lt;/<span class="name">transactionManager</span>&gt;</span></div><div class="line">      <span class="comment">&lt;!-- 数据源 --&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">dataSource</span> <span class="attr">type</span>=<span class="string">""</span>&gt;</span><span class="tag">&lt;/<span class="name">dataSource</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">environment</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">environments</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 数据库厂商标识 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">databaseIdProvider</span> <span class="attr">type</span>=<span class="string">""</span>&gt;</span><span class="tag">&lt;/<span class="name">databaseIdProvider</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 映射器：指定映射文件或者映射类 --&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="Properties"><a href="#Properties" class="headerlink" title="Properties"></a>Properties</h3><p>准备配置文件<br>~/config/db.properties<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">db.driver=com.mysql.jdbc.Driver</div><div class="line">db.url=jdbc:mysql://localhost:3306/MybatisTest1?useUnicode=true&amp;amp;characterEncoding=utf8</div><div class="line">db.username=root</div><div class="line">db.password=sqdyy.214</div></pre></td></tr></table></figure></p>
<p>可以通过properties标签，读取java配置文件的内容，例如读取数据库连接信息：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 通过properties标签，读取java配置文件的内容 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">properties</span> <span class="attr">resource</span>=<span class="string">"db.properties"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"db.username"</span> <span class="attr">value</span>=<span class="string">"errorName"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"db.password"</span> <span class="attr">value</span>=<span class="string">"errorPassword"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">properties</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p>之后你就可以在整个配置文件中使用它来动态配置属性值：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">dataSource</span> <span class="attr">type</span>=<span class="string">"POOLED"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"driver"</span> <span class="attr">value</span>=<span class="string">"$&#123;db.driver&#125;"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"url"</span> <span class="attr">value</span>=<span class="string">"$&#123;db.url&#125;"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"username"</span> <span class="attr">value</span>=<span class="string">"$&#123;db.username&#125;"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"password"</span> <span class="attr">value</span>=<span class="string">"$&#123;db.password&#125;"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">dataSource</span>&gt;</span></div><div class="line">``` </div><div class="line"></div><div class="line">需要注意的地方时我在properties元素体内配置了db.username，db.password属性，但同时也在db.properties内配置了这两个属性，那么如果我们在多处配置了相同的信息，mybatis会按照下面的顺序加载属性：</div><div class="line">- 1 在properties元素体内指定的属性首先被读取。</div><div class="line">- 2 然后resource引用的属性会被读取，并覆盖之前已读取的同名属性</div><div class="line">- 3 最后读取作为方法参数传递的属性parameterType，并覆盖之前已读取的同名属性(用不到)</div><div class="line"></div><div class="line">从Mybatis3.4.2开始增加了一个新特性，可以为占位符指定一个默认值，例如：</div><div class="line">``` xml</div><div class="line"><span class="comment">&lt;!-- 你需要手动开启这个特性 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"org.apache.ibatis.parsing.PropertyParser.enable-default-value"</span> <span class="attr">value</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line"><span class="comment">&lt;!-- 如果 'username' 没有找到，就指定值为 'root'  --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"username"</span> <span class="attr">value</span>=<span class="string">"$&#123;username:root&#125;"</span>/&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="Settings"><a href="#Settings" class="headerlink" title="Settings"></a>Settings</h3><p>这是mybatis的全局配置参数，全局参数将会影响mybatis的运行行为，由于参数很多便不一一举例，需要了解直接参考<a href="http://www.mybatis.org/mybatis-3/zh/configuration.html" target="_blank" rel="external">官档</a>即可，下面是一个配置完整的settings元素示例：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">settings</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- MyBatis对mapper解析Cache的全局开关，默认开(true) --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"cacheEnabled"</span> <span class="attr">value</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- Mybatis延迟加载全局开关，默认关(false)，如果不设置true，在服务启动的时候自动加载所有的mapper</span></div><div class="line"><span class="comment">       同时还有一个懒加载全局开关 aggressiveLazyLoading --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"lazyLoadingEnabled"</span> <span class="attr">value</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 是否允许开启多结果集返回，默认开(true) --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"multipleResultSetsEnabled"</span> <span class="attr">value</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 用列标签代替列名(暂时不懂哦) --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"useColumnLabel"</span> <span class="attr">value</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 设置是否使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"useGeneratedKeys"</span> <span class="attr">value</span>=<span class="string">"false"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 用来告诉mybatis是否需要自动映射</span></div><div class="line"><span class="comment">       NONE 表示取消自动映射；</span></div><div class="line"><span class="comment">	   PARTIAL 只会自动映射没有定义嵌套结果集映射的结果集。 </span></div><div class="line"><span class="comment">	   FULL 会自动映射任意复杂的结果集（无论是否嵌套）。</span></div><div class="line"><span class="comment">   --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"autoMappingBehavior"</span> <span class="attr">value</span>=<span class="string">"PARTIAL"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 当检测出未知列（或未知属性）时，如何处理，默认情况下没有任何提示，这在测试的时候很不方便，不容易找到错误。</span></div><div class="line"><span class="comment">       NONE : 不做任何处理 (默认值)</span></div><div class="line"><span class="comment">       WARNING : 警告日志形式的详细信息</span></div><div class="line"><span class="comment">       FAILING : 映射失败，抛出异常和详细信息</span></div><div class="line"><span class="comment">   --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"autoMappingUnknownColumnBehavior"</span> <span class="attr">value</span>=<span class="string">"WARNING"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 配置默认的执行器，默认值simple，Mybatis有三种executor：</span></div><div class="line"><span class="comment">       SimpleExecutor -- SIMPLE 就是普通的执行器。</span></div><div class="line"><span class="comment">       ReuseExecutor -执行器会重用预处理语句（prepared statements）</span></div><div class="line"><span class="comment">       BatchExecutor --它是批量执行器</span></div><div class="line"><span class="comment">   --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"defaultExecutorType"</span> <span class="attr">value</span>=<span class="string">"SIMPLE"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 设置超时时间，它决定驱动等待数据库响应的秒数。 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"defaultStatementTimeout"</span> <span class="attr">value</span>=<span class="string">"25"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 为驱动的结果集获取数量（fetchSize）设置一个提示值，可以避免jdbc内存溢出问题 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"defaultFetchSize"</span> <span class="attr">value</span>=<span class="string">"100"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 允许在嵌套语句中使用分页（RowBounds）。 If allow, set the false. --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"safeRowBoundsEnabled"</span> <span class="attr">value</span>=<span class="string">"false"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 是否开启自动驼峰命名规则(camel case)映射 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"mapUnderscoreToCamelCase"</span> <span class="attr">value</span>=<span class="string">"false"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 配置本地缓存的作用域, 默认值为 SESSION，这种情况下会缓存一个会话中执行的所有查询。  --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"localCacheScope"</span> <span class="attr">value</span>=<span class="string">"SESSION"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 当没有为参数提供特定的 JDBC 类型时，为空值指定 JDBC 类型。  --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"jdbcTypeForNull"</span> <span class="attr">value</span>=<span class="string">"OTHER"</span>/&gt;</span></div><div class="line">  <span class="comment">&lt;!-- 指定哪个对象的方法触发一次延迟加载 --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"lazyLoadTriggerMethods"</span> <span class="attr">value</span>=<span class="string">"equals,clone,hashCode,toString"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">settings</span>&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="typeAliases"><a href="#typeAliases" class="headerlink" title="typeAliases"></a>typeAliases</h3><p>别名是使用是为了在映射文件中，更方便的去指定入参和结果集的类型，不再用写很长的一段全限定名。<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 类型名称：为一些类定义别名 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">typeAliases</span>&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 单个别名定义(麻烦) --&gt;</span></div><div class="line">	<span class="comment">&lt;!-- &lt;typeAlias type="cn.sqdyy.mybatis.dao.User" alias="user"/&gt; --&gt;</span></div><div class="line"></div><div class="line">	<span class="comment">&lt;!-- 批量别名定义(推荐) --&gt;</span></div><div class="line">	<span class="comment">&lt;!-- package：指定包名称来为该包下的po类声明别名，默认的别名就是类名（首字母大小写都行user/User） --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">package</span> <span class="attr">name</span>=<span class="string">"cn.sqdyy.mybatis.dao"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">typeAliases</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p>如果被配置别名的包下的JavaBean，配置了注解@Alias(“user”)，那么别名就必须是注解值<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Alias</span>(<span class="string">"user"</span>)</div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">User</span> </span>&#123;</div><div class="line">    ...</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>同时mybatis还为许多常见的java类型内建了相应的类型别名，他们都是大小写不敏感的，如果需要使用请查阅<a href="http://www.mybatis.org/mybatis-3/zh/configuration.html" target="_blank" rel="external">官档</a></p>
<h3 id="typeHandlers"><a href="#typeHandlers" class="headerlink" title="typeHandlers"></a>typeHandlers</h3><p>无论是 MyBatis 在预处理语句（PreparedStatement）中设置一个参数时，还是从结果集中取出一个值时，都会用类型处理器将获取的值以合适的方式转换成 Java 类型。Mybatis默认为我们实现了许多TypeHandler, 当我们没有配置指定TypeHandler时，Mybatis会根据参数或者返回结果的不同，默认为我们选择合适的TypeHandler处理，下面简单介绍如何配置自定义的TypeHandler，参考<a href="http://www.cnblogs.com/dongying/p/4040435.html" target="_blank" rel="external">深入浅出Mybatis系列（五）—TypeHandler简介及配置</a>：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">typeHandlers</span>&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 当配置package的时候，mybatis会去配置的package扫描TypeHandlers</span></div><div class="line"><span class="comment">         &lt;package name="com.dy.demo"/&gt;</span></div><div class="line"><span class="comment">	--&gt;</span></div><div class="line">	<span class="comment">&lt;!-- handler属性直接配置我们要指定的TypeHandler --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">typeHandler</span> <span class="attr">handler</span>=<span class="string">""</span>/&gt;</span></div><div class="line">	<span class="comment">&lt;!-- javaType 配置java类型，例如String, 如果配上javaType, 那么指定的typeHandler就只作用于指定的类型 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">typeHandler</span> <span class="attr">javaType</span>=<span class="string">""</span> <span class="attr">handler</span>=<span class="string">""</span>/&gt;</span></div><div class="line">	<span class="comment">&lt;!-- jdbcType 配置数据库基本数据类型，例如varchar, 如果配上jdbcType, 那么指定的typeHandler就只作用于指定的类型  --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">typeHandler</span> <span class="attr">jdbcType</span>=<span class="string">""</span> <span class="attr">handler</span>=<span class="string">""</span>/&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 也可两者都配置 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">typeHandler</span> <span class="attr">javaType</span>=<span class="string">""</span> <span class="attr">jdbcType</span>=<span class="string">""</span> <span class="attr">handler</span>=<span class="string">""</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">typeHandlers</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p>假设有这样一个需求：有一个布尔型的字段需要保存到数据库中，但是数据库不支持布尔类型，因此采用一位字符char(1)来存储这个布尔值，但javabean中仍然采用boolean类型，那么这时候就需要实现数据类型的自动转换，我们可以通过实现TypeHandler接口或继承BaseTypeHandler来编写一个自定义类型转换器，参考代码如下：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// @MappedJdbcTypes(&#123;JdbcType.CHAR&#125;)</span></div><div class="line"><span class="comment">// @MappedTypes(&#123;Boolean.class&#125;)</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyDateTypeHandler</span> <span class="keyword">implements</span> <span class="title">TypeHandler</span> </span>&#123;</div><div class="line">    </div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setParameter</span><span class="params">(PreparedStatement ps, <span class="keyword">int</span> i, Object parameter, JdbcType jdbcType)</span> <span class="keyword">throws</span> SQLException </span>&#123;</div><div class="line">        Boolean b = (Boolean) parameter;</div><div class="line">        String value = (Boolean) b == <span class="keyword">true</span> ? <span class="string">"Y"</span> : <span class="string">"N"</span>;</div><div class="line">        ps.setString(i, value);</div><div class="line">    &#125;</div><div class="line">    </div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">getResult</span><span class="params">(ResultSet rs, String columnName)</span> <span class="keyword">throws</span> SQLException </span>&#123;</div><div class="line">        String str = rs.getString(columnName);</div><div class="line">        <span class="keyword">if</span>(str.equalsIgnoreCase(<span class="string">"Y"</span>)) &#123;</div><div class="line">        	<span class="keyword">return</span> <span class="keyword">true</span>;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">return</span> <span class="keyword">false</span>;</div><div class="line">    &#125;</div><div class="line">    </div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">getResult</span><span class="params">(ResultSet rs, <span class="keyword">int</span> columnIndex)</span> <span class="keyword">throws</span> SQLException </span>&#123;</div><div class="line">        String str = rs.getNString(columnIndex);</div><div class="line">        <span class="keyword">if</span>(str.equalsIgnoreCase(<span class="string">"Y"</span>)) &#123;</div><div class="line">        	<span class="keyword">return</span> <span class="keyword">true</span>;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">return</span> <span class="keyword">false</span>;</div><div class="line">    &#125;</div><div class="line">    </div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">getResult</span><span class="params">(CallableStatement cs, <span class="keyword">int</span> columnIndex)</span> <span class="keyword">throws</span> SQLException </span>&#123;</div><div class="line">        Boolean b = cs.getBoolean(columnIndex);</div><div class="line">        <span class="keyword">return</span> b == <span class="keyword">true</span> ? <span class="string">"Y"</span> : <span class="string">"N"</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>如何配置：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">typeHandlers</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">typeHandler</span> <span class="attr">javaType</span>=<span class="string">"Boolean"</span> <span class="attr">jdbcType</span>=<span class="string">"CHAR"</span> <span class="attr">handler</span>=<span class="string">"cn.sqdyy.mybatis.handler.MyDateTypeHandler"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">typeHandlers</span>&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="objectFactory"><a href="#objectFactory" class="headerlink" title="objectFactory"></a>objectFactory</h3><p>（此部分内容暂时只是了解了解，本人未实践代码）<br>默认的对象工厂需要做的仅仅是实例化目标类，要么通过默认构造方法，要么在参数映射存在的时候通过参数构造方法来实例化。它不做其他任何的处理。如果我们想在创建实例化一个目标类的时候做点啥其他的动作，可以继承DefaultObjectFactory，覆写父类方法，并在mybatis-config.xml中注册配置这个对象工厂类，例如：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ExampleObjectFactory</span> <span class="keyword">extends</span> <span class="title">DefaultObjectFactory</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">create</span><span class="params">(Class type)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> <span class="keyword">super</span>.create(type);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">create</span><span class="params">(Class type, List&lt;Class&gt; constructorArgTypes, List&lt;Object&gt; constructorArgs)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> <span class="keyword">super</span>.create(type, constructorArgTypes, constructorArgs);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setProperties</span><span class="params">(Properties properties)</span> </span>&#123;</div><div class="line">        <span class="keyword">super</span>.setProperties(properties);</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">public</span> &lt;T&gt; <span class="function"><span class="keyword">boolean</span> <span class="title">isCollection</span><span class="params">(Class&lt;T&gt; type)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> Collection.class.isAssignableFrom(type);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>注册：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">objectFactory</span> <span class="attr">type</span>=<span class="string">"org.mybatis.example.ExampleObjectFactory"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"someProperty"</span> <span class="attr">value</span>=<span class="string">"100"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">objectFactory</span>&gt;</span></div></pre></td></tr></table></figure></p>
<h3 id="plugins"><a href="#plugins" class="headerlink" title="plugins"></a>plugins</h3><p>（此部分内容暂时只是了解了解，本人未实践代码）(<a href="http://blog.csdn.net/ddddpow/article/details/9499435" target="_blank" rel="external">http://blog.csdn.net/ddddpow/article/details/9499435</a>)<br>mybatis支持插件来插入自定制的处理过程，所有的plugin都需实现Interceptor接口，自定制的处理过程可以在Executor，ParameterHandler，ResultSetHandler，StatementHandler四个处理过程中插入，原理是在使用这四中类型处理数据的时候使用的都是经过plugin处理过的代理对象。</p>
<h3 id="environments"><a href="#environments" class="headerlink" title="environments"></a>environments</h3><p>(暂时了解了解，需要配置环境的时候再来看)</p>
<h3 id="mappers"><a href="#mappers" class="headerlink" title="mappers"></a>mappers</h3><p>最后我们就需要定义sql映射语句了，我们需要告诉MyBatis到哪里去找到这些语句，有如下方法：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">mappers</span>&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 使用相对于类路径的资源 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">mapper</span> <span class="attr">resource</span>=<span class="string">"mapper/User.xml"</span> /&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 使用完全限定路径 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">mapper</span> <span class="attr">url</span>=<span class="string">"file:///root/文档/MyCode/Mybatis/MybatisTest1/config/mapper/UserMapper.xml"</span> /&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 使用mapper接口的全限定类名 </span></div><div class="line"><span class="comment">		 此种方法要求mapper接口和mapper映射文件要名称相同，且放到同一个目录下 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">mapper</span> <span class="attr">class</span>=<span class="string">"cn.sqdyy.mybatis.mapper.UserMapper"</span>/&gt;</span></div><div class="line">	<span class="comment">&lt;!-- 注册指定包下的所有映射文件(推荐)</span></div><div class="line"><span class="comment">	     此种方法要求mapper接口和mapper映射文件要名称相同，且放到同一个目录下 --&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">package</span> <span class="attr">name</span>=<span class="string">"cn.sqdyy.mybatis.mapper"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">mappers</span>&gt;</span></div></pre></td></tr></table></figure></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-12-05T09:57:59.382Z" itemprop="dateUpdated">2017年12月5日 17:57</time>
</span><br>


        如要转载请注明出处：<a href="/2017/08/13/Mybatis_primary_03/" target="_blank" rel="external">http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/</a>
    </div>
    <footer>
        <a href="http://magic_duck.oschina.io">
            <img src="/img/avatar.jpg" alt="神奇的鸭鸭">
            神奇的鸭鸭
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SSM/">SSM</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&title=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&title=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/08/13/Mybatis_primary_04/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Mybatis快速入门四(映射文件)</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/08/13/Mybatis_primary_02/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">Mybatis快速入门二(DAO开发思路)</h4>
      </a>
    </div>
  
</nav>



    







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        我只要一角钱~ ~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.png" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://git.oschina.net/z77z" target="_blank">邹海清</a></span>
            <span>神奇的鸭鸭の码农库 &copy; 2017</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&title=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&title=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Mybatis快速入门三(全局配置)》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://magic_duck.oschina.io/2017/08/13/Mybatis_primary_03/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



lazyScripts.push('//s95.cnzz.com/z_stat.php?id=1261081671&web_id=1261081671')

</script>

<script src="/js/main.min.js?v=1.4.3"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.4.3" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


</body>
</html>
